package com.tangguo.vshop.web;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.tangguo.vshop.domain.Mainbody;
import com.tangguo.vshop.domain.User;
import com.tangguo.vshop.repository.MainbodyRepository;
import com.tangguo.vshop.repository.UserRepository;

@RestController
@RequestMapping("/user")
public class UserController {
	@Autowired
	private UserRepository userRepository;
	@Autowired
	private MainbodyRepository mainbodyRepository;
	
	@RequestMapping(method = RequestMethod.GET)
    public List<User> getUsers() {
		Mainbody mainbody = mainbodyRepository.findOne("5943319930f3f802f4eb4f6b");
		User user = new User();
		user.setMainbody(mainbody);
		user.setCreateTime(new Date());
		user.setDescription("cest");
		userRepository.save(user);
		
        return userRepository.findAll();
    }
	
}
